<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Karamelo: Input scripts</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="karamelodoxy.css" rel="stylesheet" type="text/css">
<!--  -->
<script type="text/javascript" src="karamelo_navtree_hacks.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.karamelo.org"><img alt="Logo" src="Karamelo_logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://www.karamelo.org">Karamelo</a>
   &#160;<span id="projectnumber">714599e9</span>
   </div>
   <div id="projectbrief">Parallel Material Point Method Simulator</div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('InputScripts.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title"><a class="el" href="classInput.html">Input</a> scripts </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><b>Karamelo</b> executes by reading commands from a input script (a text file), one line at a time. When the input script ends, <b>Karamelo</b> exits. Each command causes <b>Karamelo</b> to take some action. It may set a variable, read in a file, or run a simulation. The syntax used is easy and flexible. One can for example intuitively add new variables that can be constant: </p><div class="fragment"><div class="line">E = 211</div></div><!-- fragment --><p> or depend on internal variables such as time – using the time variable – or the particle positions – using the x, y or z variables: </p><div class="fragment"><div class="line">T = 1</div><div class="line">r = sqrt(x*x+y*y)</div><div class="line">g = sin(PI*time/T)</div></div><!-- fragment --><p> The list of internal variable to date are: </p><a class="anchor" id="multi_row"></a>
<table class="doxtable">
<caption>Internal variables</caption>
<tr>
<th>Variable </th><th>Description </th></tr>
<tr>
<td>x0 </td><td>Particle or node position in the x direction in the reference state. </td></tr>
<tr>
<td>y0 </td><td>Particle or node position in the y direction in the reference state. </td></tr>
<tr>
<td>z0 </td><td>Particle or node position in the z direction in the reference state. </td></tr>
<tr>
<td>x </td><td>Current particle or node position in the x direction. </td></tr>
<tr>
<td>y </td><td>Current particle or node position in the y direction. </td></tr>
<tr>
<td>z </td><td>Current particle or node position in the z direction. </td></tr>
<tr>
<td>time </td><td>Current simulation time. </td></tr>
<tr>
<td>timestep </td><td>Current time step. </td></tr>
<tr>
<td>dt </td><td>Current timestep, i.e. \(\Delta t\). </td></tr>
<tr>
<td>PI </td><td>Number \(\pi\). </td></tr>
</table>
<p>Everything else is controlled through functions. For instance, the global dimensionality of the simulation, the domain’s size, and the background grid cell size are set by the dimension() command, for example: </p><div class="fragment"><div class="line">dimension(2, xlo, xhi, ylo, yhi, cellsize)</div></div><!-- fragment --><p>Just like with programming languages, ordering of commands in an input script can be important. The following rules apply: </p><ol>
<li>
<p class="startli"><b>Karamelo</b> does not read your entire input script and then perform a simulation with all the settings. Rather, the input script is read one line at a time and each command takes effect when it is read. Thus this sequence of commands:<br />
</p><div class="fragment"><div class="line">set_dt(0.001)</div><div class="line">run(100)</div><div class="line">run(100)</div></div><!-- fragment --><p>does something different than:</p>
<div class="fragment"><div class="line">run(100)</div><div class="line">set_dt(0.001)</div><div class="line">run(100)</div></div><!-- fragment --><p>In the first case, the specified timestep (0.001) is used for two simulations of 100 timesteps each. In the 2nd case, the timestep corresponding to the CFL condition is used for the 1st 100 step simulation and a 0.001 timestep is used for the 2nd one.</p>
<p class="endli"></p>
</li>
<li>
<p class="startli">A user variable cannot be used before it's defined. Therefore this code<br />
</p><div class="fragment"><div class="line">E = 2 * a</div></div><!-- fragment --><p> returns </p><div class="fragment"><div class="line"><a class="code" href="classError.html">Error</a> at line 1: <a class="code" href="classError.html">Error</a>: a is unknown.</div></div><!-- fragment --><p class="endli"></p>
</li>
<li>
All characters from the first '#' character onward are treated as comment and discarded. Example: <div class="fragment"><div class="line"><span class="preprocessor"># This is a comment</span></div><div class="line"><span class="preprocessor">dt_factor(0.1)  # This is another comment</span></div></div><!-- fragment --> </li>
</ol>
<p>But don't worry too much as many input script errors are detected by <b>Karamelo</b> and an ERROR or WARNING message is printed. </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Tue Jul 7 2020 22:31:23 for Karamelo by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
<!-- Matomo -->
<script type="text/javascript">
  var _paq = _paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//stats.sylphide-consulting.com/matomo/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '20']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<noscript><p><img src="//stats.sylphide-consulting.com/matomo/piwik.php?idsite=20&rec=1" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->
</body>
</html>
